package com.test.daily.leetcode.y2021.m12.day1204;

/**
 * @descriptions: Code01_MaxEnergy
 * @author: Tom
 * @date: 2021/12/1 上午 10:52
 * @version: 1.0
 */
public class Code01_MaxEnergy {
    public static void main(String[] args) {
        Code01_MaxEnergy ce = new Code01_MaxEnergy();
        System.out.println(ce.maxPower("tourist"));
        System.out.println(ce.maxPower("hooraaaaaaaaaaay"));
    }

    public int maxPower(String s) {
        int ans = 0;
        if (s == null || s.length() == 0) {
            return ans;
        }
        int N = s.length();
        int start = 0;
        int end = 0;
        while (start < N) {
            while ((end < N) && (s.charAt(start) == s.charAt(end))) {
                end++;
            }
            ans = Math.max(end - start, ans);
            start = end;
        }
        return ans;
    }
}
